home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15291 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: news.cern.ch!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question about C compiler
  5. Date: 18 Apr 96 10:09:40 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.829822180@news.cern.ch>
  8. References: <1996Apr16.175344.6042@lafn.org>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=US-ASCII
  12. Content-Transfer-Encoding: 7bit
  13. X-Newsreader: NN version 6.5.0 #18 (NOV)
  14.  
  15. In <1996Apr16.175344.6042@lafn.org> av871@lafn.org (Karl Chen) writes:
  16.  
  17.  
  18. >    In C and C++ ,there is a way to allocate and dealloacte memory 
  19. >dynamically ( in C,using malloc() and free(),In C++,using new and delete)
  20. >.I heard from a book
  21.  
  22. Wow, you have a talking book! :-)    
  23.  
  24. >that some compiler do not delete the pointer after
  25. >deallocation,is this true?Why they don't do this ?
  26.  
  27. To answer these questions, I would need to know what you mean by
  28. "deleting a pointer".  If you mean, setting the pointer to NULL after
  29. deallocation, the answer is obvious if you actually try to think at it
  30. for one minute.
  31.  
  32. Clue1: reading the FAQ may help.
  33.  
  34. Clue2: function arguments are passed by value in C.  (Yes, a smartass
  35. could argue that free() is a special case and the compiler could legally
  36. pass its argument by address or generate the right code to nullify the
  37. pointer right after the free() call, but this is not what happens in the 
  38. real world.)
  39.  
  40. >What about Boland C++
  41. >? 
  42.  
  43. "Boland C++" is no exception.  It treats free() as an ordinary function.
  44.  
  45. >Can anyone give me a advice ?
  46.  
  47. If it's important to you, set the pointer to NULL right after calling
  48. free().
  49.  
  50. >      Thankx !!!Please e-mail me
  51.  
  52. If you're too lazy to scan the newsgroup for answers, you don't deserve
  53. them.
  54.  
  55. Dan
  56. --
  57. Dan Pop
  58. CERN, CN Division
  59. Email: danpop@mail.cern.ch 
  60. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  61.